package com.qf.day09.lxjk;

import java.util.Random;

/**
 * 英雄
 */
public class Hero implements Flyable,jk2able{

    private String name;  //名字
    private int strength;  //力量
    private int intellect;  //智力
    private int agile;  //敏捷

    public Hero(String name) {
        this.name = name;
    }

    /**
     * 普通攻击
     *
     * @return 返回普通攻击后的伤害
     */
    public int NormalAttack(int strength){
        int random = random(strength);
        System.out.println("本次普通攻击造成的伤害为:"+random);
//        return random;
        return random;
    }
//    写一个随机数 力量上下百分之20
    public int random(int strength){
//       double NormalAttack = strength*0.2;
        Random random = new Random();
        int max = (int) (strength*0.2+100);
        int min = (int) (strength-100*0.2);
        int ran = random.nextInt((max-min+1)+min);
        return ran;
    }
    //有参无参GET SET

    public Hero() {
    }

    public Hero(String name, int strength, int intellect, int agile) {
        this.name = name;
        this.strength = strength;
        this.intellect = intellect;
        this.agile = agile;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getStrength() {
        return strength;
    }

    public void setStrength(int strength) {
        this.strength = strength;
    }

    public int getIntellect() {
        return intellect;
    }

    public void setIntellect(int intellect) {
        this.intellect = intellect;
    }

    public int getAgile() {
        return agile;
    }

    public void setAgile(int agile) {
        this.agile = agile;
    }

    @Override
    public String toString() {
        return "Hero{" +
                "name='" + name + '\'' +
                ", strength=" + strength +
                ", intellect=" + intellect +
                ", agile=" + agile +
                '}';
    }

    @Override
    public void fly() {
        System.out.println(this.name+"在飞");
    }

    @Override
    public void eat() {
        System.out.println(this.name+"在吃");
    }

    @Override
    public void swim() {
        System.out.println(this.name+"在游泳");
    }

    @Override
    public boolean tf() {
        if(this.name.equals("小丑")){
        return true;
        }else {
            return false;
        }
    }

}
